package com.qf.controller;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/mq")
public class MQController {
    private RabbitTemplate rabbitTemplate;

    @Autowired
    public void setRabbitTemplate(RabbitTemplate rabbitTemplate) {
        this.rabbitTemplate = rabbitTemplate;
    }

    @RequestMapping("/fanout")
    public String sendFanout(String message){
        rabbitTemplate.convertAndSend("2102fanout", "", message);
        return "succer";
    }
    @RequestMapping("/direct")
    public String sendDirect(String message,String key){
        rabbitTemplate.convertAndSend("bk2102EXCHANGE1",key, message);
        return "成功aa";
    }

    @RequestMapping("/topic")
    public String sendTopic(String message,String key){

        rabbitTemplate.convertAndSend("qwe",key,message);
        return "成功1111111tocpic";
    }


}
